package com.chao.tlias.controller;
/**
 * 班级控制器
 */

import com.chao.tlias.Pojo.PageBean;
import com.chao.tlias.Pojo.Result;
import com.chao.tlias.service.ClazzService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Slf4j
@RestController()
@RequestMapping("/clazzs")
public class ClazzController {

    @Autowired
    private ClazzService clazzService;

    @GetMapping
    public Result selPage(String name,
                          @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                          @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end,
                          @RequestParam(defaultValue = "1") Integer page,
                          @RequestParam(defaultValue = "10")Integer pageSize) {
        log.info("分页查询班级数据,{},{},{},{},{}", page, pageSize,name,begin,end);
        PageBean pageBean = clazzService.page(page,pageSize,name,begin,end);

        return Result.success(pageBean);
    }

}
